<?php
/**
* 短信控制器
*/
class Common extends MY_Controller
{
	
	function __construct()
	{
		parent::__construct();
	}
	/**
	 * 检测验证码是否有效
	 * @DateTime 2017-07-20
	 * @author zyl
	 * @return   [type]     [description]
	 */
	function validCode(){
		$this->load->model('Merchant_model', 'merchant');
		$code = $_GET['code'];
		$ret = $this->merchant->checkCode($code);
		if($ret){
			$return = array('code'=>1,'msg'=>'推荐码有效');
		}else{
			$return = array('code'=>0,'msg'=>'推荐码无效');
		}
		echo json_encode($return);
	}

	/**
	 * 获取app用户信息
	 * @DateTime 2017-08-17
	 * @author zyl
	 * @return   [type]     [description]
	 */
	function getAppUserInfo()
	{
		header("Access-Control-Allow-Origin: *");
		
		$post = $this->input->post();

		$userinfo = json_decode($post['userinfo'],true);
		
		if(isset($userinfo['id']) && $userinfo['id'] >0){
			$_SESSION['userinfo'] = $userinfo;
		}

		if(isset($_SESSION['userinfo']) && !empty($_SESSION['userinfo'])){
			$return = array('code'=>1,'msg'=>'操作成功');
		}else{
			$return = array('code'=>0,'msg'=>'操作失败');
		}

		echo json_encode($return);
	}

	
}